#import "OrderIndexViewController.h"
#import "CYOrderViewController.h"
@interface OrderIndexViewController ()
{
    NSArray *list;
}
@property (nonatomic, strong) MLMSegmentHead *segHead;
@property (nonatomic, strong) MLMSegmentScroll *segScroll;
@end
@implementation OrderIndexViewController
-(void)viewDidLoad
{
    [super viewDidLoad];
    [self segmentStyle1];
}
-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    self.tabBarController.tabBar.hidden = YES;
    [self.navigationController setNavigationBarHidden:YES animated:animated];
}
- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    self.tabBarController.tabBar.hidden = NO;
    [self.navigationController setNavigationBarHidden:NO animated:animated];
}
- (void)dealloc
{
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}
#pragma mark - <QMUITextFieldDelegate>
- (BOOL)textFieldShouldReturn:(QMUITextField *)textField {
    return NO;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}
- (void)segmentStyle1 {
    list = IsCurrentUserMale ? @[ASLocalizedString(@"魅力")] : @[ASLocalizedString(@"财气")];
    UIButton *search = [[UIButton alloc] init];
    search.frame = CGRectMake(3, StatusBarHeight - 5, 50, 50);
    [search setImage:[UIImage imageNamed:@"nav_back"] forState:UIControlStateNormal];
    [search addTarget:self action:@selector(handleBackEvent) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:search];
    UIButton *order = [[UIButton alloc] init];
    order.frame = CGRectMake(SCREEN_WIDTH - 50, StatusBarHeight - 5, 50, 50);
    [self.view addSubview:order];
    _segHead = [[MLMSegmentHead alloc] initWithFrame:CGRectMake(54, StatusBarHeight, SCREEN_WIDTH - 54 - 54, 40) titles:list headStyle:SegmentHeadStyleLine layoutStyle:_layout];
    _segHead.selectColor = MainColor;
    _segHead.deSelectColor = [UIColor blackColor];
    _segHead.lineColor = MainColor;
    _segHead.fontScale = 1;
    _segHead.lineHeight = 1.3;
    _segHead.fontSize = 15;
    _segHead.lineScale = .9;
    _segHead.headColor = CF6;
    _segHead.bottomLineHeight = 0;
    self.view.backgroundColor = CF6;
    _segScroll = [[MLMSegmentScroll alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(_segHead.frame), SCREEN_WIDTH, SCREEN_HEIGHT-CGRectGetMaxY(_segHead.frame)) vcOrViews:[self vcArr:list.count]];
    _segScroll.loadAll = NO;
    _segScroll.showIndex = 0;
    [MLMSegmentManager associateHead:_segHead withScroll:_segScroll completion:^{
        [self.view addSubview:_segHead];
        [self.view addSubview:_segScroll];
    }];
}
- (void)handleBackEvent {
    [self.navigationController popViewControllerAnimated:YES];
}
#pragma mark - 数据源
- (NSArray *)vcArr:(NSInteger)count {
    NSMutableArray *arr = [NSMutableArray array];
    CYOrderViewController *order1 = [CYOrderViewController new];
    order1.isHidenNaviBar = YES;
    order1.type = @"1";
    CYOrderViewController *order2 = [CYOrderViewController new];
    order2.type = @"2";
    [arr addObject:IsCurrentUserMale ? order1 : order2];
    return arr;
}
@end
